﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Adex;
using MediaMonitor.Common;
using Telerik.Web.UI;


namespace MediaMonitor.Admin
{
    public partial class SetUserAsAdminstrator : System.Web.UI.Page
    {
        DateTime sDate = DateTime.MinValue, eDate = DateTime.MinValue;
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
                BindDDL();
        }
        protected void radGridAll_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            ReportFuncs rpt = new ReportFuncs();
            DataTable dt = rpt.GetReportAllUser();
            radGridAll.DataSource = dt;
        }
        public void BindDDL()
        {
            ReportFuncs rpt = new ReportFuncs();
            DataTable dt = rpt.GetReportAllRoles();
            ddlRoles.DataSource = dt;
            ddlRoles.DataTextField = "RoleName";
            ddlRoles.DataValueField = "RoleID";
            ddlRoles.DataBind();
        }
        protected void imgbtnSave_click(object sender, EventArgs e)
        {
            try
            {
                String SelectedUser = String.Empty;
                string selectedRole = ddlRoles.SelectedValue;
                foreach (Telerik.Web.UI.GridItem itm in radGridAll.SelectedItems)
                {
                    SelectedUser +=  radGridAll.MasterTableView.DataKeyValues[itm.ItemIndex]["UserID"].ToString() + ",";
                }
                SelectedUser = SelectedUser.Remove(SelectedUser.Length - 1);
                TblComment.Updaterole(SelectedUser, selectedRole);
            }
            catch (Exception ex2)
            {
            }
        }
    }
}